<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="author" content="Lei Shi">
		<meta http-equiv="Cache-Control" content="o-transform">
		<meta http-equiv="Cache-Control" content="no-siteapp">
		<title>发表新帖 - 智慧教育平台</title>

		<link rel="shortcut icon" href="favicon.ico">
		<link rel="stylesheet" href="../static/font-awesome//4.7.0/css/font-awesome.min.css">
		<link rel="stylesheet" href="../static/highlight.js/9.8.0/monokai-sublime.min.css">
		<link rel="stylesheet" href="../app/css/libs/bootstrap/3.3.7/css/bootstrap.min.css">
		<link rel="stylesheet" href="../app/css/libs/katex/0.6.0/katex.min.css">
		<link rel="stylesheet" href="../app/css/libs/videojs/5.11.7/video-js.min.css">
		<link rel="stylesheet" href="../app/css/dest/styles.css?=2016121272249">

		<link rel="stylesheet" type="text/css" href="../css/bootstrap-theme.min.css">
		<link rel="stylesheet" type="text/css" href="../css/muke.css">
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css" />
		<script src="../layui/layui.js"></script>
		<script src="../js/jquery.min.js"></script>
		<script src="../js/vue.min.js"></script>
		<script src="../js/axios.js"></script>
		<script src="../js/index.js"></script>

		<style>

			/* modal 模态框*/
        #invite-user .modal-body {
            overflow: hidden;
        }
		#invite-user .modal-body .form-label {
			margin-bottom: 16px;
			font-size:14px;
		}
		#invite-user .modal-body .form-invite {
			width: 80%;
			padding: 6px 12px;
			background-color: #eeeeee;
			border: 1px solid #cccccc;
			border-radius: 5px;
			float: left;
			margin-right: 10px;
		}
		#invite-user .modal-body .msg-modal-style {
			background-color: #7dd383;
			margin-top: 10px;
			padding: 6px 0;
			text-align: center;
			width: 100%;
		}
		#invite-user .modal-body .modal-flash {
			position: absolute;
			top: 53px;
			right: 74px;
			z-index: 999;
		}
		/* end modal */

        .en-footer {
            padding: 30px;
            text-align: center;
            font-size: 14px;
        }
    </style>
		<script type="text/javascript">
			if(sessionStorage.getItem("access_token")!=null){
				axios.defaults.headers.common['Authorization'] = "bearer " + sessionStorage.getItem("access_token");
			}
			
			layui.use('layedit', function() {
				var layedit = layui.layedit,
					$ = layui.jquery;
				var index = layedit.build('demo'); //建立编辑器

				var postContent;
				var active = {
					content: function() {
						postContent = layedit.getContent(index);
						//alert(layedit.getContent(index)); //获取编辑器内容
					},
					text: function() {
						alert(layedit.getText(index)); //获取编辑器纯文本内容
					},
					selection: function() {
						alert(layedit.getSelection(index));
					}
				};

				var token = sessionStorage.getItem("access_token");
				if (token == null) {
					layer.confirm('您还没有登录，是否登录？', {
						icon: 3,
						title: '提示',
					}, function(index) {
						window.location.href = "\\login.html?callback-url=http://127.0.0.1/bbs/Reception/post.html";
					}, function(index) {
						window.location.href = "post.html";
					});
				}

				$("#btn_public").on('click', function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';

					var postTitle = $("#postTitle").val();

					if (postContent == "" || postTitle == "") {
						layer.msg("请完善帖子信息", {
							icon: 7,
							time: 1000,
						});
					} else {

						$.ajax({
							url: '/api/bbs/post/insertPost',
							type: 'post',
							data: {
								content: postContent,
								title: postTitle,
								userId: sessionStorage.getItem("userid")
							},
			//	
							headers:{
								'Authorization': 'bearer '+sessionStorage.getItem("access_token")
								
							},
							beforeSend: function(request) {
								// 禁用按钮防止重复提交
								$("#btn_public").attr({
									disabled: "disabled"
								});
								//设置请求头
								//request.setRequestHeader("BBG-Key", "ab9ef204-3253-49d4-b229-3cc2383480a6");
							},
							success: function(data) {
								if (data.success) {
									layer.msg(data.message, {
										icon: 6, //成功的表情 
										time: 1000, //1秒关闭（如果不配置，默认是3秒） 
									}, function() {
										window.location.href = "post.html";
									});

								} else {
									layer.msg(data.message, {
										icon: 5,
										time: 1000,
									});
									return;
								}
							},

						});
					}
				})

			});
		</script>


	</head>

	<body>


		<!-- 顶部 -->
		<div class="width100 float_l" style="margin-top: -70px;">
			<div class="width100 float_l height80 line_hei80">

				<!-- 顶部左边 -->
				<div class="float_l">
					<div class="float_l margin_l20">
						<a href="#"><img src="../img/uiz1.png"></a>
					</div>
					<div class="float_l">
						<ul class="ul_li fon_siz16">
							<li><a class="color_black" href="../courses/index.html">课程</a></li>
							<li><a class="color_black" href="">院系</a></li>
							<li><a class="color_black" href="">名师专栏</a></li>

						</ul>
					</div>
				</div>

				<!-- 顶部右边 -->
				<div class="float_r">
					<div class="float_l top_input">
						<input class="posi_relative" type="text" name="" id="" placeholder="请输入想搜索的内容...">
						<img class="img_sousuo bianshou" src="../img/uiz4.png">
					</div>
					<div class="float_l margin_l20">
						<img src="../img/uiz5.png">
					</div>
					<div class="float_l margin_l35">
						<img src="../img/uiz6.png">
					</div>
				</div>

			</div>
		</div>



		<div class="container layout layout-margin-top">

			<ol class="breadcrumb">
				<li><a href="post.html">讨论区</a></li>
				<li><a href="#">发表新帖</a></li>
			</ol>

			<div class="row">
				<div class="col-md-9 layout-body">

					<div class="content question-detail">

						<label class="layui-form-label">标题</label>
						<br />
						<br />
						<input type="text" id="postTitle" name="title" required lay-verify="required" placeholder="请输入标题" autocomplete="off"
						 class="layui-input">
						</input>

						<label class="layui-form-label">内容</label>
						<br />
						<br />
						<div class="your-answer words-ctrl">
							<textarea id="demo" id="public"></textarea>
							<br />
							<button class="layui-btn" data-type="content" id="btn_public">发表新帖</button>
						</div>
					</div>

				</div>
				<div class="col-md-3 layout-side">

					<div class="panel panel-default panel-userinfo">
						<div class="panel-body body-userinfo">
							<div class="media userinfo-header">
								<div class="media-left">
									<div class="user-avatar">
					
										<a class="avatar" href="#sign-modal" data-toggle="modal" data-sign="signin">
											<img class="circle" src="../img/logo-grey.png">
										</a>
					
									</div>
								</div>
								<div class="media-body">
					
									<span class="media-heading username">欢迎来到智慧教育平台</span>
									<p class="vip-remain">做实验，学编程</p>
					
								</div>
							</div>
					
							<div class="userinfo-footer row">
								<div class="col-md-6 col-xs-6 pos-left">
					
									<a href="#sign-modal" data-toggle="modal" data-sign="signin"><span class="glyphicon glyphicon-bookmark"></span>
										加入私有课</a>
					
								</div>
								<div class="col-md-6 col-xs-6 pos-right">
									<a href="/contribute" target="_blank"><span class="glyphicon glyphicon-send"></span> 我要投稿</a>
								</div>
					
								<div id="join-private-course" class="modal fade words-ctrl" tabindex="-1" role="dialog">
									<div class="modal-dialog" role="document">
										<div class="modal-content">
											<div class="modal-header">
												<h4 class="modal-title">加入私有课</h4>
											</div>
											<div class="modal-body">
												<div style="margin:15px 0; font:16px;">输入教师提供的私有课程码可以加入教师的私有课程。</div>
												<form id="private-course-form" method="POST" action="/courses/join">
													<div class="form-group">
														<label for="code">邀请码</label>
														<input class="form-control" id="code" name="code" type="text" value="">
														<input name="_csrf_token" type=hidden value="1483789088##bbf83c51243ab12daa94911c8865a65bdc66c4d8">
													</div>
												</form>
					
											</div>
											<div class="modal-footer">
												<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
												<button type="button" class="btn btn-primary" onclick="document.getElementById('private-course-form').submit();">确定</button>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>

				</div>
			</div>

		</div>


		<!-- 页脚 -->
		<div class="width100 float_l padding_t30 height193">
			<div class="width_1200 margin_auto">
				<div class="width100 float_l text_c margin_b30">
					<a class="img_backg5" href="#"></a>
					<a class="img_backg6 posi_relative wexinmaxianshi" href="#"><i class="weixinweima dis_none"><img src="img/idx-btm.png"></i></a>
					<a class="img_backg7" href="#"></a>
					<a class="img_backg8" href="#"></a>
				</div>
				<div class="width100 float_l text_c yejiao color_gray">
					<a>关于我们</a>
					<a>企业合作</a>
					<a>人才招聘</a>
					<a>讲师招募</a>
					<a>联系我们</a>
					<a>意见反馈</a>
					<a>友情链接</a>
				</div>
				<div class="width100 float_l text_c border_t margin_t20 padding_t20 color_gray fon_siz12">
					<span>© 2016 imoroc.com 京ICP备13042132号</span>
				</div>
			</div>
		</div>


	</body>
</html>
